<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateAttendanceDailyPointTrace extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('attendance_daily_point_trace', function (Blueprint $table) {
            $table->id();

            $table->unsignedBigInteger("dailyGatherId")->default(0)->comment("attendance_daily_gather.id");
            $table->unsignedBigInteger("userId")->default(0)->comment("rmsUserID");
            $table->date("date")->nullable(true)->comment("日期");

            $table->unsignedInteger("tracePointTime")->default(0)->comment("轨迹点位时间");

            $table->string("deviceModel", 64)->default("")->comment("登录设备型号");
            $table->string("deviceSystem", 64)->default("")->comment("登录设备系统");
            $table->string("deviceSerialNumber", 120)->default("")->comment("登录设备序列号");

            $table->unsignedTinyInteger("gpsSwitch")->default(0)->comment("gps状态 0 - 关闭 1 - 开启");
            $table->unsignedTinyInteger("wifiSwitch")->default(0)->comment("wifi状态 0 - 关闭 1 - 开启");
            $table->unsignedTinyInteger("cellularNetworkSwitch")->default(0)->comment("蜂窝网络状态 0 - 关闭 1 - 开启");
            $table->unsignedTinyInteger("dumpEnergy")->default(0)->comment("剩余电量");
            $table->string("longitude", 36)->default("")->comment("经度");
            $table->string("latitude", 36)->default("")->comment("纬度");
            $table->unsignedInteger("lastPointDistance")->default(0)->comment("距离上一点位距离");
            $table->unsignedInteger("lastPointTime")->default(0)->comment("距离上一点位时间");
            $table->unsignedTinyInteger("status")->default(0)->comment("点位状态 0 - 移动 1 - 停留");
            $table->string("address")->default("")->comment("详细地址");

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');

            $table->collation = 'utf8mb4_general_ci';
            $table->comment   = '考勤每日轨迹表';
            $table->index(["dailyGatherId"], "idx_dailyGatherId");
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('attendance_daily_point_trace');
    }
}
